package net.scalan.jpa;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

/**
 * Utility class for dealing with persistence.
 *
 * @author scalan
 */
public final class PersistenceService {
    private static EntityManagerFactory emf = null;

    public static synchronized EntityManager getEntityManager() {
        if (emf == null) {
            emf = Persistence.createEntityManagerFactory(Common.EntityManagerFactoryName);
        }
        return emf.createEntityManager();
    }
}
